define([
    'modules/ApiClient',
	'modules/config',
    "jquery",
    'jquery.cookie'
], function (ApiClient,config, $){
	var seletejcmc = function(){
        alert("zzh");
		ApiClient.get(config.EGSWEBAPI+'GemzName').then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
                
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
    };
	
	var egsinit = function(tid){
        
		var url = config.EGSWEBAPI+'Login/'+tid;
		alert(url);
		ApiClient.get(url,'').then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
                
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
    };
	
	var userGetGempoint = function(jwt){
        alert(jwt);
		var json_params={
			id:'c8f8020f-51a0-4dec-8f6d-e0be98a9c481'
			//PasswordHash:'111111'//,
			//client_id:'password_client'//'password_client'
		}
		alert(config.EGSWEBAPI+'Gempoint');
		//var jwt='eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJ3eWgiLCJzdWIiOm51bGwsIlJvbGUiOiIiLCJqdGkiOiI4ZWQzMDJjOS1jYzFlLTRhMDctYTNmNC1hOWMzYWRiOTE5NWEiLCJleHAiOiJcL0RhdGUoMTUzNzUwOTMxNTEyMClcLyIsImlhdCI6IlwvRGF0ZSgxNTM3NTAyMTE1MTIwKVwvIiwiSWQiOiJjOGY4MDIwZi01MWEwLTRkZWMtOGY2ZC1lMGJlOThhOWM0ODEifQ.FB3KiV1sVW_yK--xgCMEZ_MLzaBBpNNMEyCfs5-hORWVs7rz7zRnwLmoAWxK5zg1vtqrGxy9wdwAOzbjWotEzg';
		ApiClient.get(config.EGSWEBAPI+'Gempoint',jwt).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
                
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
    };
	
	var Validatejcmc = function(stoken){
		alert(stoken);
		ApiClient.get(config.EGSWEBAPI+'Validate/150124-004',stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	}
	
	var Creatyd = function(stoken){
		alert(stoken);
		var json_params={
			SAMPLEPLOTID:"150124-004-2018", 
                SAMPLEPLOTNAME:"woshini",
                CJDATA:"2018-1-24",
                JLR:"韩王亚",
                XZDM:"150700",
                XZMC:"呼伦贝尔市",
                DXDMDM:"04",
                DXDMMC:"平原",
                PXDM:"",
                PXMC:"",
                PWDM:"",
                PWMC:"",
                PD:"",
                TRLXDM:"04",
                TRLXMC:"栗钙土",
                ZBLXDM:"02",
                ZBLXMC:"典型草原",
                ZWQL:" 贝加尔针茅+大针茅+羊草",
                DLWDM:"02",
                DLWMC:"凋落物(少)",
                LSDM:"01",
                LSMC:"砾石(无)",
                FSDM:"02",
                FSMC:"风蚀（坑）(少)",
                LKDM:"02",
                LKMC:"立枯(无)",
                FUSDM:"02",
                FUSMC:"覆沙(少)",
                SSDM:"02",
                SSMC:"水蚀（沟）(少)",
                YJBDM:"01",
                YJBMC:"盐碱斑(无)",
                LYFSDM:"05",
                LYFSMC:"打草场",
                LYQDDM:"02",
                LYQDMC:"轻度",
                ZLLX:"围封",
                SHBZ:"000000"
		}
		ApiClient.post(config.EGSWEBAPI+'SampleArea',json_params,stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	}
	
	var Updateyd = function(stoken){
		alert(stoken);
		var json_params={
			SAMPLEPLOTID:"150124-005-2018", 
                SAMPLEPLOTNAME:"青豆沟",
                CJDATA:"2018-9-26",
                JLR:"EG152500审核",
                XZDM:"150700",
                XZMC:"呼伦贝尔市",
                DXDMDM:"04",
                DXDMMC:"平原",
                PXDM:"",
                PXMC:"",
                PWDM:"",
                PWMC:"",
                PD:"",
                TRLXDM:"04",
                TRLXMC:"栗钙土",
                ZBLXDM:"02",
                ZBLXMC:"典型草原",
                ZWQL:" 贝加尔针茅+大针茅+羊草",
                DLWDM:"02",
                DLWMC:"凋落物(少)",
                LSDM:"01",
                LSMC:"砾石(无)",
                FSDM:"02",
                FSMC:"风蚀（坑）(少)",
                LKDM:"02",
                LKMC:"立枯(无)",
                FUSDM:"02",
                FUSMC:"覆沙(少)",
                SSDM:"02",
                SSMC:"水蚀（沟）(少)",
                YJBDM:"01",
                YJBMC:"盐碱斑(无)",
                LYFSDM:"05",
                LYFSMC:"打草场",
                LYQDDM:"02",
                LYQDMC:"轻度",
                ZLLX:"围封",
                SHBZ:"000000"
		}
		ApiClient.put(config.EGSWEBAPI+'SampleArea',json_params,stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	}
	
	var Deleteyd = function(stoken){
		alert(stoken);
		var json_params={
			id:"150124-004-201805-0153"
		}
		ApiClient.delparams(config.EGSWEBAPI+'SampleArea',json_params,stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	}
	var Selectyd = function(stoken){
		alert(stoken);
		ApiClient.get(config.EGSWEBAPI+'SampleArea/150124-008-201805-0149',stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	}
	/*******************************************************操作草本样方***************************************************/
	var addGrass = function(stoken){
		alert(stoken);
		var json_params={
  "SAMPLEPLOTNAME": "???????????",
  "SAMPLEPLOTID": "152900-004-2018",
  "GRASSID": 1,
  "YFMJ": "1",
  "ZGD": "9.8",
  "PJGD": "5.2",
  "SHBZ": "0,0,0",
  "PICNAME": "",
  "GRASS_WZ": [
    {
      "WZMC": "?????",
      "ZCS": 3,
      "ZGDONE": 4,
      "ZGDTWO": 5,
      "ZGDTHREE": 5,
      "ZGDFOUR": 0,
      "ZGDFIVE": 0,
      "SWLXZ": 2.63,
      "SWLGZ": 1.11,
      "ZGDAVG": "4.67"
    },
    {
      "WZMC": "????",
      "ZCS": 2,
      "ZGDONE": 15,
      "ZGDTWO": 13,
      "ZGDTHREE": 0,
      "ZGDFOUR": 0,
      "ZGDFIVE": 0,
      "SWLXZ": 5.67,
      "SWLGZ": 2.48,
      "ZGDAVG": "14.00"
    },
    {
      "WZMC": "???",
      "ZCS": 35,
      "ZGDONE": 10,
      "ZGDTWO": 6,
      "ZGDTHREE": 7,
      "ZGDFOUR": 10,
      "ZGDFIVE": 6,
      "SWLXZ": 11.98,
      "SWLGZ": 4.4,
      "ZGDAVG": "7.80"
    },
    {
      "WZMC": "??",
      "ZCS": 20,
      "ZGDONE": 1,
      "ZGDTWO": 1,
      "ZGDTHREE": 1,
      "ZGDFOUR": 1,
      "ZGDFIVE": 1,
      "SWLXZ": 3.58,
      "SWLGZ": 1.04,
      "ZGDAVG": "1.00"
    },
    {
      "WZMC": "????",
      "ZCS": 6,
      "ZGDONE": 4,
      "ZGDTWO": 3,
      "ZGDTHREE": 3,
      "ZGDFOUR": 2,
      "ZGDFIVE": 3,
      "SWLXZ": 1.36,
      "SWLGZ": 0.75,
      "ZGDAVG": "3.00"
    },
    {
      "WZMC": "???",
      "ZCS": 2,
      "ZGDONE": 12,
      "ZGDTWO": 6,
      "ZGDTHREE": 0,
      "ZGDFOUR": 0,
      "ZGDFIVE": 0,
      "SWLXZ": 1.2,
      "SWLGZ": 0.56,
      "ZGDAVG": "9.00"
    },
    {
      "WZMC": "???",
      "ZCS": 2,
      "ZGDONE": 1,
      "ZGDTWO": 1,
      "ZGDTHREE": 0,
      "ZGDFOUR": 0,
      "ZGDFIVE": 0,
      "SWLXZ": "<0.1",
      "SWLGZ": "<0.1",
      "ZGDAVG": "1.00"
    },
    {
      "WZMC": "???",
      "ZCS": 3,
      "ZGDONE": 10,
      "ZGDTWO": 5,
      "ZGDTHREE": 4,
      "ZGDFOUR": 0,
      "ZGDFIVE": 0,
      "SWLXZ": 3.25,
      "SWLGZ": 0.64,
      "ZGDAVG": "6.33"
    },
    {
      "WZMC": "????",
      "ZCS": 2,
      "ZGDONE": 3,
      "ZGDTWO": 4,
      "ZGDTHREE": 0,
      "ZGDFOUR": 0,
      "ZGDFIVE": 0,
      "SWLXZ": 2.87,
      "SWLGZ": 0.59,
      "ZGDAVG": "3.50"
    },
    {
      "WZMC": "????",
      "ZCS": 320,
      "ZGDONE": 1,
      "ZGDTWO": 1,
      "ZGDTHREE": 2,
      "ZGDFOUR": 1,
      "ZGDFIVE": 1,
      "SWLXZ": 12,
      "SWLGZ": 3.22,
      "ZGDAVG": "1.20"
    }
  ]
}

		ApiClient.post(config.EGSWEBAPI+'GrassQuadrat',json_params,stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	}
	
	var UpdateGrass = function(stoken){
		alert(stoken);
		var json_params={
  "SAMPLEPLOTNAME": "查干敖包坡下",
  "SAMPLEPLOTID": "152500-001-2018",
  "GRASSID": "152500-001-2018-CB-1",
  "YFMJ": "10",
  "ZGD": "10",
  "PJGD": "10",
  "SHBZ": "",
  "PICNAME": "",
  "VERSION": "10/18/2018 9:24:41 AM",
  "GRASS_WZ": [
    {
      "ID": 4768,
      "GRASSID": "152500-001-2018-CB-1",
      "WZDM": "d1139",
      "WZMC": "加拿大雀麦",
      "ZGDONE": 1,
      "ZGDTWO": 1,
      "ZGDTHREE": 1,
      "ZGDFOUR": 1,
      "ZGDFIVE": 1,
      "ZGDAVG": 1,
      "CFLENGTH": 0,
      "CFWIDTH": 0,
      "ZCS": 1,
      "SWLXZ": "1",
      "SWLGZ": "1",
      "BZ": "1111",
      "SHBZ": "0",
      "VERSION": "10/18/2018 9:24:41 AM",
      "DBMARK": 2
    }
  ]
}
		ApiClient.put(config.EGSWEBAPI+'GrassQuadrat',json_params,stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	}
	var DeleteGrass = function(stoken){
		alert(stoken);
		var json_params={
			id:"-CB-1"
		}
		ApiClient.delparams(config.EGSWEBAPI+'GrassQuadrat',json_params,stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	}
	var SelectGrass = function(stoken){
		alert(stoken);
		ApiClient.get(config.EGSWEBAPI+'GrassQuadrat/150700-005-201808',stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	};
	/*******************************************************操作灌木样方***************************************************/
	var addShrub = function(stoken){
		alert(stoken);
		var json_params={ 
            SAMPLEPLOTID: "150124-111-2018",
            SAMPLEPLOTNAME: "yueye1", 
			SHRUBID: "01",
            YFMJ: 5,
            ZGD: 2222,
            SHBZ:"000001",
			PICNAME:"",
			SHRUB_WZ:[ 
            {
             CFLENGTH:1,
             CFWIDTH:1,
             WZDM:"d2012",
             WZMC:"细叶鸢尾", 
             ZCS:23,
             SHBZ:"00000000",
             WZGD:10,
            }, 
            {
                CFLENGTH:1,
                CFWIDTH:1,
                WZDM:"d1916",
                WZMC:"无芒隐子草", 
                ZCS:23,
                SHBZ:"00000000",
                WZGD:12,
            }
          ]
        }
		ApiClient.post(config.EGSWEBAPI+'ShrubQuadrat',json_params,stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	}
	var updateShrub = function(stoken){
		alert(stoken);
		var json_params={ 
            SAMPLEPLOTID: "150124-111-2018",
            SAMPLEPLOTNAME: "yueye1", 
			SHRUBID: "150124-111-2018-GM-01",
            YFMJ: 50,
            ZGD: 30,
            SHBZ:"000001",
			PICNAME:"",
			VERSION:"2018/9/27 21:17:20",
			SHRUB_WZ:[ 
            {
				ID:'1411',
				CFLENGTH:1,
				CFWIDTH:1,
				WZDM:"d2012",
				WZMC:"细叶鸢尾", 
				ZCS:1,
				SHBZ:"00000000",
				WZGD:50,
				DBMARK:"2",
				VERSION:"2018/9/27 21:17:20"
            }, 
            {
				ID:'1412',
                CFLENGTH:1,
                CFWIDTH:1,
                WZDM:"d1916",
                WZMC:"无芒隐子草", 
                ZCS:1,
                SHBZ:"00000000",
                WZGD:51,
				DBMARK:"3",
				VERSION:"2018/9/27 21:17:20"
            }, 
            {
                CFLENGTH:1,
                CFWIDTH:1,
                WZDM:"d526",
                WZMC:"野大麻", 
                ZCS:1,
                SHBZ:"00000000",
                WZGD:51,
				DBMARK:"1"//,
				//VERSION:"2018/9/27 11:17:00"
            }
          ]
        }
		ApiClient.put(config.EGSWEBAPI+'ShrubQuadrat',json_params,stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	}
	var DeleteShrub = function(stoken){
		alert(stoken);
		var json_params={
			id:"152500-005-201808-0028-GM-1"
		}
		ApiClient.delparams(config.EGSWEBAPI+'ShrubQuadrat',json_params,stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	}
	var SelectShrub = function(stoken){
		alert(stoken);
		ApiClient.get(config.EGSWEBAPI+'ShrubQuadrat/152500-007-201808-0027',stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	};
	/*******************************************************操作频度样方***************************************************/
	var addFrequency = function(stoken){
		alert(stoken);
		var json_params={
              GRASSID:"",
			  XZDM:"150700",
			  XZMC:"150700",
			  CJDATA:"2018/9/27",
			  lon:110.5,
			  lat:45.8,
              FREQUENCYWZ:[
               {  
                WZDM:"d1390",
                WZMC:"麻花",
                WZPD:"110000000001010101000000"
               },
               {
                WZDM:"d1396",
                WZMC:"麻花78",
                WZPD:"110000000001010101000000"
               }
             ]
        };
		ApiClient.post(config.EGSWEBAPI+'FrequencyQuadrat',json_params,stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	};
	
	var updateFrequency = function(stoken){
		alert(stoken);
		var json_params={
              GRASSID:"PD-EG152500-2018-000019",
			  XZDM:"150700",
			  XZMC:"150700",
			  ZWQL:"贝加尔针茅+大针茅",
			  LYQDDM:"03",
			  LYQDMC:"中度",
			  CJDATA:"2018/9/27",
			  VERSION:"2018/9/28 15:13:56",
			  lon:120.5,
			  lat:48.8,
              FREQUENCYWZ:[
               {  
			    ID:"663",
                WZDM:"d1390",
                WZMC:"麻花",
                WZPD:"110000000001010101000000",
				VERSION:"2018/9/28 15:11:10",
				DBMARK:"2"
               },
               {
				ID:"664",
                WZDM:"d1396",
                WZMC:"麻花78",
                WZPD:"110000000001010101000000",
				VERSION:"2018/9/28 15:11:10",
				DBMARK:"3"
               },
               {
                WZDM:"d526",
                WZMC:"野大麻",
                WZPD:"110000000001010101000000",
				VERSION:"",
				DBMARK:"1"
               }
             ]
        };
		ApiClient.put(config.EGSWEBAPI+'FrequencyQuadrat',json_params,stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	};
	
	var DeleteFrequency = function(stoken){
		alert(stoken);//PD-150700-201507-0001
		var json_params={
			id:"PD-150700-201507-0001"
		}
		ApiClient.delparams(config.EGSWEBAPI+'FrequencyQuadrat',json_params,stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	};
	
	var SelectFrequency = function(stoken){
		alert(stoken);
		ApiClient.get(config.EGSWEBAPI+'FrequencyQuadrat/PD-150700-2018-000002',stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	};
	
	var ydEvalInsert = function(stoken){
		alert(stoken);
		var json_params={
			GEMPOINTID:"150700-013",
			YEAR:"2018",
			EVALVALUE:"04",
			EVALMC:"良好"
		}
		ApiClient.post(config.EGSWEBAPI+'gempointeval',json_params,stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	};
	
	var ydEvalSelect = function(stoken){
		alert(stoken);
		var json_params={
			ydid:"150700-013",
			syear:"2018"
		}
		ApiClient.getparams(config.EGSWEBAPI+'gempointeval',json_params,stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	};
	
	var seletejczzmc = function(stoken){
		alert(stoken);
		ApiClient.get(config.EGSWEBAPI+'GemzName',stoken).then(function (reValues) {
					console.log(reValues);
					alert(reValues.data.code);
					if (reValues.data.code == "200") {
						alert(reValues.data.reRows);
						alert(reValues.data.reMessage);
					} else if (reValues.data.code == "401") {
                
					} else {
					
					}
				});
	};
	
	
    return {
        seletejcmc:seletejcmc,
		egsinit:egsinit,
		userGetGempoint:userGetGempoint,
		Validatejcmc:Validatejcmc,
		Creatyd:Creatyd,
		Updateyd:Updateyd,
		Deleteyd:Deleteyd,
		Selectyd:Selectyd,
		addGrass:addGrass,
		UpdateGrass:UpdateGrass,
		DeleteGrass:DeleteGrass,
		SelectGrass:SelectGrass,
		addShrub:addShrub,
		updateShrub:updateShrub,
		DeleteShrub:DeleteShrub,
		SelectShrub:SelectShrub,
		addFrequency:addFrequency,
		updateFrequency:updateFrequency,
		DeleteFrequency:DeleteFrequency,
		SelectFrequency:SelectFrequency,
		ydEvalInsert:ydEvalInsert,
		ydEvalSelect:ydEvalSelect,
		seletejczzmc:seletejczzmc
    }
});